define([], function(){
	var tpl = {};
	
	tpl.init = function(domId){
		var html = navbar();
		$("#"+domId).html(html);
	}
	
	tpl.initLoading = function(domId){
		var html = loading();
		$("#"+domId).html(html);
	}
	
	tpl.initError = function(domId){
		var html = error();
		$("#"+domId).html(html);
	}
	
	tpl.initCrumb = function(domId){
		var html = crumb();
		$("#"+domId).html(html);
	}

	tpl.initTopbar = function(domId){
		var html = topbar();
		$("#"+domId).html(html);
	}
	
	var navbar = function(){
		return 	'<script id="tpl_navbar" type="text/html">'+
				'	{{each childrens as nav i}}'+
				'		<li>'+
				'			{{if nav.type=="leaf"}}'+
				'				<a data-name="{{nav.name}}" data-icon="{{nav.icon}}" data-id="{{nav.id}}" data-config="{{nav.config}}" data-type="leaf">'+
				'					<i class="{{nav.icon}}"></i>'+
				'					<span>{{nav.alias}}</span>'+
				'				</a>'+
				'			{{else if nav.type=="catalog"}}'+
				'				<a data-name="{{nav.name}}" data-icon="{{nav.icon}}" data-type="catalog">'+
				'					<i class="{{nav.icon}}"></i>'+
				'					<span>{{nav.alias}}</span>'+
				'					<i class="pull-right fa fa-angle-right"></i>'+
				'				</a>'+
				'			{{/if}}'+
				'			{{if nav.childrens!=null&&nav.childrens.length>0}}'+
				'				<ul>{{include "tpl_navbar",nav}}</ul>'+
				'			{{/if}}'+
				'		</li>'+
				'	{{/each}}'+
			    '</script>';
	}
	
	var loading = function(){
		return 	'<script id="tpl_loading" type="text/html">'+
				'	<div class="lc-content-loading">'+
				'		<div class="loader-inner ball-pulse">'+
				'			<div></div>'+
				'			<div></div>'+
				'			<div></div>'+
				'		</div>'+
				'	</div>'+
			    '</script>';
	}
	

	var error = function(){
		return 	'<script id="tpl_error" type="text/html">'+
				'	<div class="lc-content-error">'+
				'		<div class="content">'+
				'			<i class="icon-exclamation-sign"></i>'+
				'			{{content}}'+
				'		</div>'+
				'	</div>'+
			    '</script>';
	}
	
	var crumb = function(){
		return 	'<script id="tpl_crumb" type="text/html">'+
				'	<ol class="breadcrumb">'+
				'		{{each crumbs as crumb i}}'+
				'			<li class="active {{ i == 0 ? "" : "breadcrumbli" }}" data-name="{{ (i == 0 ? "" : crumb.name) }}">'+
				'				{{if i==0}}'+
				'					<i class="{{crumb.icon}}"></i>'+
				'				{{/if}}'+
				'				{{crumb.alias}}'+
				'			</li>'+
				'		</div>'+
				'		{{/each}}'+
				'	</ol>'+
			    '</script>';
	}

	var topbar = function(){
		return 	'<script id="tpl_topbar" type="text/html">'+
				'	<ul>'+
				'		{{each topbars as topbar i}}'+
				'			<li {{if topbar.id}}id="{{topbar.id}}"{{/if}}><i class="{{topbar.icon}}"></i>{{topbar.name}}</li>'+
				'		{{/each}}'+
				'	</ul>'+
			    '</script>';
	}

	return tpl;
});